layui.define('setter', function (exports) {
    var $ = layui.jquery,
        setter = layui.setter,
        isEmpty = function (str) {
            if (typeof str == null || str == "" || str == undefined || str == "undefined") {
                return true;
            } else {
                return false;
            }
        },
        //网络配置        
        // host_url = 'http://127.0.0.1:5000/api/';
        //host_url = 'http://192.168.1.28:5000/api/';
        // host_url = 'http://192.168.1.57:5000/api/';
        //host_url = 'http://192.168.1.28:8005/api/';
        host_url = 'https://rgk.spsy.org/api/';

    var yjUrl = {
        find: function (keyId) {
            var returnUrl = {
                urlType: '',
                urlPath: host_url + keyId
            };
            return returnUrl;
        },
        ztzrFind: function (keyId) {
            var returnUrl;
            if (keyId.indexOf('/') == -1) {
                //这里报错说明URL的命名规则错误：Key:命名规则是模块_UrlKey(防止重复) 
                var keyIndex = keyId.indexOf('_');
                var moduleName = keyId.substring(0, keyIndex);
                var keyName = keyId.substring(keyIndex, keyId.Length);
                if (moduleName == 'main') {
                    //如果有admin模块，就用admin模块，否则用main模块
                    if (!isEmpty(UrlPath['admin_Path'])) {
                        moduleName = 'admin';
                        keyId = moduleName + keyName;
                    }
                }
                var data = UrlPath[moduleName + '_Path'][keyId];
                if (setter.UrlDebug == 1) { //只用本地数据
                    returnUrl = {
                        urlType: 'get',
                        urlPath: data.local_Url
                    };
                } else if (setter.UrlDebug == 0) { //网上数据没有，用本地数据 
                    if (isEmpty(data.net_Url)) {
                        returnUrl = {
                            urlType: 'get',
                            urlPath: data.local_Url
                        };
                    } else {
                        returnUrl = {
                            urlType: '',
                            urlPath: data.net_Url
                        };
                    }
                } else if (setter.UrlDebug == 2) { //只用网上数据
                    returnUrl = {
                        urlType: '',
                        urlPath: data.net_Url
                    };
                } else {
                    returnUrl = '';
                }
            } else if (keyId == "QMimg") {
                returnUrl = img_url;
            } else {
                returnUrl = {
                    urlType: '',
                    urlPath: host_url + keyId
                };
            }
            return returnUrl;
        }
    };

    exports('yjUrl', yjUrl);
});